package painter;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Stroke;
import java.awt.geom.CubicCurve2D;

public class BezierDrawable extends ShapeDrawable {

	private Point start;
	private Point ctrl1;
	private Point ctrl2;
	private Point end;
	
	public BezierDrawable(int epaisseur, Color color, Point start, Point ctrl1, Point ctrl2, Point end) {
		super(epaisseur, color);
		
		this.start = start;
		this.ctrl1 = ctrl1;
		this.ctrl2 = ctrl2;
		this.end = end;
	}
	
	
	@Override
	public void draw(Graphics g) {
		Graphics2D graphic = (Graphics2D)g;
		
		Stroke s = graphic.getStroke();
		Color c = graphic.getColor();
		
		graphic.setColor(color);
		graphic.setStroke(new BasicStroke(epaisseur));
		
		graphic.draw(new CubicCurve2D.Double(start.x, start.y, ctrl1.x, ctrl1.y, ctrl2.x, ctrl2.y, end.x, end.y));
		
		graphic.setColor(c);
		graphic.setStroke(s);
	}

}
